<?php


/**
 * Base class that represents a query for the 'user_positions' table.
 *
 *
 *
 * @method EmpevalUserPositionsQuery orderById($order = Criteria::ASC) Order by the id column
 * @method EmpevalUserPositionsQuery orderByUserId($order = Criteria::ASC) Order by the user_id column
 * @method EmpevalUserPositionsQuery orderByPositionId($order = Criteria::ASC) Order by the position_id column
 * @method EmpevalUserPositionsQuery orderByUnitId($order = Criteria::ASC) Order by the unit_id column
 * @method EmpevalUserPositionsQuery orderByIsFirst($order = Criteria::ASC) Order by the is_first column
 * @method EmpevalUserPositionsQuery orderByIsSuperior($order = Criteria::ASC) Order by the is_superior column
 * @method EmpevalUserPositionsQuery orderByActive($order = Criteria::ASC) Order by the active column
 * @method EmpevalUserPositionsQuery orderByActiveDate($order = Criteria::ASC) Order by the active_date column
 * @method EmpevalUserPositionsQuery orderByDeactiveDate($order = Criteria::ASC) Order by the deactive_date column
 * @method EmpevalUserPositionsQuery orderByCreated($order = Criteria::ASC) Order by the created column
 *
 * @method EmpevalUserPositionsQuery groupById() Group by the id column
 * @method EmpevalUserPositionsQuery groupByUserId() Group by the user_id column
 * @method EmpevalUserPositionsQuery groupByPositionId() Group by the position_id column
 * @method EmpevalUserPositionsQuery groupByUnitId() Group by the unit_id column
 * @method EmpevalUserPositionsQuery groupByIsFirst() Group by the is_first column
 * @method EmpevalUserPositionsQuery groupByIsSuperior() Group by the is_superior column
 * @method EmpevalUserPositionsQuery groupByActive() Group by the active column
 * @method EmpevalUserPositionsQuery groupByActiveDate() Group by the active_date column
 * @method EmpevalUserPositionsQuery groupByDeactiveDate() Group by the deactive_date column
 * @method EmpevalUserPositionsQuery groupByCreated() Group by the created column
 *
 * @method EmpevalUserPositionsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method EmpevalUserPositionsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method EmpevalUserPositionsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method EmpevalUserPositionsQuery leftJoinUnits($relationAlias = null) Adds a LEFT JOIN clause to the query using the Units relation
 * @method EmpevalUserPositionsQuery rightJoinUnits($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Units relation
 * @method EmpevalUserPositionsQuery innerJoinUnits($relationAlias = null) Adds a INNER JOIN clause to the query using the Units relation
 *
 * @method EmpevalUserPositionsQuery leftJoinPositions($relationAlias = null) Adds a LEFT JOIN clause to the query using the Positions relation
 * @method EmpevalUserPositionsQuery rightJoinPositions($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Positions relation
 * @method EmpevalUserPositionsQuery innerJoinPositions($relationAlias = null) Adds a INNER JOIN clause to the query using the Positions relation
 *
 * @method EmpevalUserPositionsQuery leftJoinUsers($relationAlias = null) Adds a LEFT JOIN clause to the query using the Users relation
 * @method EmpevalUserPositionsQuery rightJoinUsers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Users relation
 * @method EmpevalUserPositionsQuery innerJoinUsers($relationAlias = null) Adds a INNER JOIN clause to the query using the Users relation
 *
 * @method EmpevalUserPositionsQuery leftJoinBonusGoalsForms($relationAlias = null) Adds a LEFT JOIN clause to the query using the BonusGoalsForms relation
 * @method EmpevalUserPositionsQuery rightJoinBonusGoalsForms($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BonusGoalsForms relation
 * @method EmpevalUserPositionsQuery innerJoinBonusGoalsForms($relationAlias = null) Adds a INNER JOIN clause to the query using the BonusGoalsForms relation
 *
 * @method EmpevalUserPositionsQuery leftJoinViewBgfWithSuperiorPositionIdRelatedByUserPositionId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedByUserPositionId relation
 * @method EmpevalUserPositionsQuery rightJoinViewBgfWithSuperiorPositionIdRelatedByUserPositionId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedByUserPositionId relation
 * @method EmpevalUserPositionsQuery innerJoinViewBgfWithSuperiorPositionIdRelatedByUserPositionId($relationAlias = null) Adds a INNER JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedByUserPositionId relation
 *
 * @method EmpevalUserPositionsQuery leftJoinViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId($relationAlias = null) Adds a LEFT JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId relation
 * @method EmpevalUserPositionsQuery rightJoinViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId relation
 * @method EmpevalUserPositionsQuery innerJoinViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId($relationAlias = null) Adds a INNER JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId relation
 *
 * @method EmpevalUserPositions findOne(PropelPDO $con = null) Return the first EmpevalUserPositions matching the query
 * @method EmpevalUserPositions findOneOrCreate(PropelPDO $con = null) Return the first EmpevalUserPositions matching the query, or a new EmpevalUserPositions object populated from the query conditions when no match is found
 *
 * @method EmpevalUserPositions findOneById(int $id) Return the first EmpevalUserPositions filtered by the id column
 * @method EmpevalUserPositions findOneByUserId(int $user_id) Return the first EmpevalUserPositions filtered by the user_id column
 * @method EmpevalUserPositions findOneByPositionId(int $position_id) Return the first EmpevalUserPositions filtered by the position_id column
 * @method EmpevalUserPositions findOneByUnitId(int $unit_id) Return the first EmpevalUserPositions filtered by the unit_id column
 * @method EmpevalUserPositions findOneByIsFirst(boolean $is_first) Return the first EmpevalUserPositions filtered by the is_first column
 * @method EmpevalUserPositions findOneByIsSuperior(boolean $is_superior) Return the first EmpevalUserPositions filtered by the is_superior column
 * @method EmpevalUserPositions findOneByActive(boolean $active) Return the first EmpevalUserPositions filtered by the active column
 * @method EmpevalUserPositions findOneByActiveDate(string $active_date) Return the first EmpevalUserPositions filtered by the active_date column
 * @method EmpevalUserPositions findOneByDeactiveDate(string $deactive_date) Return the first EmpevalUserPositions filtered by the deactive_date column
 * @method EmpevalUserPositions findOneByCreated(string $created) Return the first EmpevalUserPositions filtered by the created column
 *
 * @method array findById(int $id) Return EmpevalUserPositions objects filtered by the id column
 * @method array findByUserId(int $user_id) Return EmpevalUserPositions objects filtered by the user_id column
 * @method array findByPositionId(int $position_id) Return EmpevalUserPositions objects filtered by the position_id column
 * @method array findByUnitId(int $unit_id) Return EmpevalUserPositions objects filtered by the unit_id column
 * @method array findByIsFirst(boolean $is_first) Return EmpevalUserPositions objects filtered by the is_first column
 * @method array findByIsSuperior(boolean $is_superior) Return EmpevalUserPositions objects filtered by the is_superior column
 * @method array findByActive(boolean $active) Return EmpevalUserPositions objects filtered by the active column
 * @method array findByActiveDate(string $active_date) Return EmpevalUserPositions objects filtered by the active_date column
 * @method array findByDeactiveDate(string $deactive_date) Return EmpevalUserPositions objects filtered by the deactive_date column
 * @method array findByCreated(string $created) Return EmpevalUserPositions objects filtered by the created column
 *
 * @package    propel.generator.empeval.om
 */
abstract class EmpevalBaseUserPositionsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of EmpevalBaseUserPositionsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_empeval', $modelName = 'EmpevalUserPositions', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new EmpevalUserPositionsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     EmpevalUserPositionsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return EmpevalUserPositionsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof EmpevalUserPositionsQuery) {
            return $criteria;
        }
        $query = new EmpevalUserPositionsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   EmpevalUserPositions|EmpevalUserPositions[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = EmpevalUserPositionsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(EmpevalUserPositionsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   EmpevalUserPositions A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, USER_ID, POSITION_ID, UNIT_ID, IS_FIRST, IS_SUPERIOR, ACTIVE, ACTIVE_DATE, DEACTIVE_DATE, CREATED FROM user_positions WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new EmpevalUserPositions();
            $obj->hydrate($row);
            EmpevalUserPositionsPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return EmpevalUserPositions|EmpevalUserPositions[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|EmpevalUserPositions[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(EmpevalUserPositionsPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(EmpevalUserPositionsPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the user_id column
     *
     * Example usage:
     * <code>
     * $query->filterByUserId(1234); // WHERE user_id = 1234
     * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34)
     * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12
     * </code>
     *
     * @see       filterByUsers()
     *
     * @param     mixed $userId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByUserId($userId = null, $comparison = null)
    {
        if (is_array($userId)) {
            $useMinMax = false;
            if (isset($userId['min'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::USER_ID, $userId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($userId['max'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::USER_ID, $userId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::USER_ID, $userId, $comparison);
    }

    /**
     * Filter the query on the position_id column
     *
     * Example usage:
     * <code>
     * $query->filterByPositionId(1234); // WHERE position_id = 1234
     * $query->filterByPositionId(array(12, 34)); // WHERE position_id IN (12, 34)
     * $query->filterByPositionId(array('min' => 12)); // WHERE position_id > 12
     * </code>
     *
     * @see       filterByPositions()
     *
     * @param     mixed $positionId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByPositionId($positionId = null, $comparison = null)
    {
        if (is_array($positionId)) {
            $useMinMax = false;
            if (isset($positionId['min'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::POSITION_ID, $positionId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($positionId['max'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::POSITION_ID, $positionId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::POSITION_ID, $positionId, $comparison);
    }

    /**
     * Filter the query on the unit_id column
     *
     * Example usage:
     * <code>
     * $query->filterByUnitId(1234); // WHERE unit_id = 1234
     * $query->filterByUnitId(array(12, 34)); // WHERE unit_id IN (12, 34)
     * $query->filterByUnitId(array('min' => 12)); // WHERE unit_id > 12
     * </code>
     *
     * @see       filterByUnits()
     *
     * @param     mixed $unitId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByUnitId($unitId = null, $comparison = null)
    {
        if (is_array($unitId)) {
            $useMinMax = false;
            if (isset($unitId['min'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::UNIT_ID, $unitId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($unitId['max'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::UNIT_ID, $unitId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::UNIT_ID, $unitId, $comparison);
    }

    /**
     * Filter the query on the is_first column
     *
     * Example usage:
     * <code>
     * $query->filterByIsFirst(true); // WHERE is_first = true
     * $query->filterByIsFirst('yes'); // WHERE is_first = true
     * </code>
     *
     * @param     boolean|string $isFirst The value to use as filter.
     *              Non-boolean arguments are converted using the following rules:
     *                * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *                * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     *              Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByIsFirst($isFirst = null, $comparison = null)
    {
        if (is_string($isFirst)) {
            $is_first = in_array(strtolower($isFirst), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::IS_FIRST, $isFirst, $comparison);
    }

    /**
     * Filter the query on the is_superior column
     *
     * Example usage:
     * <code>
     * $query->filterByIsSuperior(true); // WHERE is_superior = true
     * $query->filterByIsSuperior('yes'); // WHERE is_superior = true
     * </code>
     *
     * @param     boolean|string $isSuperior The value to use as filter.
     *              Non-boolean arguments are converted using the following rules:
     *                * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *                * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     *              Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByIsSuperior($isSuperior = null, $comparison = null)
    {
        if (is_string($isSuperior)) {
            $is_superior = in_array(strtolower($isSuperior), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::IS_SUPERIOR, $isSuperior, $comparison);
    }

    /**
     * Filter the query on the active column
     *
     * Example usage:
     * <code>
     * $query->filterByActive(true); // WHERE active = true
     * $query->filterByActive('yes'); // WHERE active = true
     * </code>
     *
     * @param     boolean|string $active The value to use as filter.
     *              Non-boolean arguments are converted using the following rules:
     *                * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
     *                * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
     *              Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByActive($active = null, $comparison = null)
    {
        if (is_string($active)) {
            $active = in_array(strtolower($active), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::ACTIVE, $active, $comparison);
    }

    /**
     * Filter the query on the active_date column
     *
     * Example usage:
     * <code>
     * $query->filterByActiveDate('2011-03-14'); // WHERE active_date = '2011-03-14'
     * $query->filterByActiveDate('now'); // WHERE active_date = '2011-03-14'
     * $query->filterByActiveDate(array('max' => 'yesterday')); // WHERE active_date > '2011-03-13'
     * </code>
     *
     * @param     mixed $activeDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByActiveDate($activeDate = null, $comparison = null)
    {
        if (is_array($activeDate)) {
            $useMinMax = false;
            if (isset($activeDate['min'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::ACTIVE_DATE, $activeDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($activeDate['max'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::ACTIVE_DATE, $activeDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::ACTIVE_DATE, $activeDate, $comparison);
    }

    /**
     * Filter the query on the deactive_date column
     *
     * Example usage:
     * <code>
     * $query->filterByDeactiveDate('2011-03-14'); // WHERE deactive_date = '2011-03-14'
     * $query->filterByDeactiveDate('now'); // WHERE deactive_date = '2011-03-14'
     * $query->filterByDeactiveDate(array('max' => 'yesterday')); // WHERE deactive_date > '2011-03-13'
     * </code>
     *
     * @param     mixed $deactiveDate The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByDeactiveDate($deactiveDate = null, $comparison = null)
    {
        if (is_array($deactiveDate)) {
            $useMinMax = false;
            if (isset($deactiveDate['min'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::DEACTIVE_DATE, $deactiveDate['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($deactiveDate['max'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::DEACTIVE_DATE, $deactiveDate['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::DEACTIVE_DATE, $deactiveDate, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(EmpevalUserPositionsPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(EmpevalUserPositionsPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query by a related EmpevalUnits object
     *
     * @param   EmpevalUnits|PropelObjectCollection $units The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUnits($units, $comparison = null)
    {
        if ($units instanceof EmpevalUnits) {
            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::UNIT_ID, $units->getId(), $comparison);
        } elseif ($units instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::UNIT_ID, $units->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUnits() only accepts arguments of type EmpevalUnits or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Units relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function joinUnits($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Units');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Units');
        }

        return $this;
    }

    /**
     * Use the Units relation Units object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalUnitsQuery A secondary query class using the current class as primary query
     */
    public function useUnitsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUnits($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Units', 'EmpevalUnitsQuery');
    }

    /**
     * Filter the query by a related EmpevalPositions object
     *
     * @param   EmpevalPositions|PropelObjectCollection $positions The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByPositions($positions, $comparison = null)
    {
        if ($positions instanceof EmpevalPositions) {
            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::POSITION_ID, $positions->getId(), $comparison);
        } elseif ($positions instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::POSITION_ID, $positions->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByPositions() only accepts arguments of type EmpevalPositions or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Positions relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function joinPositions($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Positions');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Positions');
        }

        return $this;
    }

    /**
     * Use the Positions relation Positions object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalPositionsQuery A secondary query class using the current class as primary query
     */
    public function usePositionsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinPositions($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Positions', 'EmpevalPositionsQuery');
    }

    /**
     * Filter the query by a related EmpevalUsers object
     *
     * @param   EmpevalUsers|PropelObjectCollection $users The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUsers($users, $comparison = null)
    {
        if ($users instanceof EmpevalUsers) {
            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::USER_ID, $users->getId(), $comparison);
        } elseif ($users instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::USER_ID, $users->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByUsers() only accepts arguments of type EmpevalUsers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Users relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function joinUsers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Users');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Users');
        }

        return $this;
    }

    /**
     * Use the Users relation Users object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalUsersQuery A secondary query class using the current class as primary query
     */
    public function useUsersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUsers($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Users', 'EmpevalUsersQuery');
    }

    /**
     * Filter the query by a related EmpevalBonusGoalsForms object
     *
     * @param   EmpevalBonusGoalsForms|PropelObjectCollection $bonusGoalsForms  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByBonusGoalsForms($bonusGoalsForms, $comparison = null)
    {
        if ($bonusGoalsForms instanceof EmpevalBonusGoalsForms) {
            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::ID, $bonusGoalsForms->getUserPositionId(), $comparison);
        } elseif ($bonusGoalsForms instanceof PropelObjectCollection) {
            return $this
                ->useBonusGoalsFormsQuery()
                ->filterByPrimaryKeys($bonusGoalsForms->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByBonusGoalsForms() only accepts arguments of type EmpevalBonusGoalsForms or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the BonusGoalsForms relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function joinBonusGoalsForms($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('BonusGoalsForms');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'BonusGoalsForms');
        }

        return $this;
    }

    /**
     * Use the BonusGoalsForms relation BonusGoalsForms object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalBonusGoalsFormsQuery A secondary query class using the current class as primary query
     */
    public function useBonusGoalsFormsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinBonusGoalsForms($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'BonusGoalsForms', 'EmpevalBonusGoalsFormsQuery');
    }

    /**
     * Filter the query by a related EmpevalViewBgfWithSuperiorPositionId object
     *
     * @param   EmpevalViewBgfWithSuperiorPositionId|PropelObjectCollection $viewBgfWithSuperiorPositionId  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByViewBgfWithSuperiorPositionIdRelatedByUserPositionId($viewBgfWithSuperiorPositionId, $comparison = null)
    {
        if ($viewBgfWithSuperiorPositionId instanceof EmpevalViewBgfWithSuperiorPositionId) {
            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::ID, $viewBgfWithSuperiorPositionId->getUserPositionId(), $comparison);
        } elseif ($viewBgfWithSuperiorPositionId instanceof PropelObjectCollection) {
            return $this
                ->useViewBgfWithSuperiorPositionIdRelatedByUserPositionIdQuery()
                ->filterByPrimaryKeys($viewBgfWithSuperiorPositionId->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByViewBgfWithSuperiorPositionIdRelatedByUserPositionId() only accepts arguments of type EmpevalViewBgfWithSuperiorPositionId or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedByUserPositionId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function joinViewBgfWithSuperiorPositionIdRelatedByUserPositionId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('ViewBgfWithSuperiorPositionIdRelatedByUserPositionId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'ViewBgfWithSuperiorPositionIdRelatedByUserPositionId');
        }

        return $this;
    }

    /**
     * Use the ViewBgfWithSuperiorPositionIdRelatedByUserPositionId relation ViewBgfWithSuperiorPositionId object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalViewBgfWithSuperiorPositionIdQuery A secondary query class using the current class as primary query
     */
    public function useViewBgfWithSuperiorPositionIdRelatedByUserPositionIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinViewBgfWithSuperiorPositionIdRelatedByUserPositionId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'ViewBgfWithSuperiorPositionIdRelatedByUserPositionId', 'EmpevalViewBgfWithSuperiorPositionIdQuery');
    }

    /**
     * Filter the query by a related EmpevalViewBgfWithSuperiorPositionId object
     *
     * @param   EmpevalViewBgfWithSuperiorPositionId|PropelObjectCollection $viewBgfWithSuperiorPositionId  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   EmpevalUserPositionsQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId($viewBgfWithSuperiorPositionId, $comparison = null)
    {
        if ($viewBgfWithSuperiorPositionId instanceof EmpevalViewBgfWithSuperiorPositionId) {
            return $this
                ->addUsingAlias(EmpevalUserPositionsPeer::ID, $viewBgfWithSuperiorPositionId->getSuperiorUserPositionId(), $comparison);
        } elseif ($viewBgfWithSuperiorPositionId instanceof PropelObjectCollection) {
            return $this
                ->useViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionIdQuery()
                ->filterByPrimaryKeys($viewBgfWithSuperiorPositionId->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId() only accepts arguments of type EmpevalViewBgfWithSuperiorPositionId or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function joinViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId');
        }

        return $this;
    }

    /**
     * Use the ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId relation ViewBgfWithSuperiorPositionId object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   EmpevalViewBgfWithSuperiorPositionIdQuery A secondary query class using the current class as primary query
     */
    public function useViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'ViewBgfWithSuperiorPositionIdRelatedBySuperiorUserPositionId', 'EmpevalViewBgfWithSuperiorPositionIdQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   EmpevalUserPositions $userPositions Object to remove from the list of results
     *
     * @return EmpevalUserPositionsQuery The current query, for fluid interface
     */
    public function prune($userPositions = null)
    {
        if ($userPositions) {
            $this->addUsingAlias(EmpevalUserPositionsPeer::ID, $userPositions->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
